<?php
    //热销手机
    $sql = "
    select
    i.iname,g.gname,g.price,g.msg,g.id
    from
    ".PRE."goods as g,".PRE."image as i,".PRE."category as c
    where
    g.id = i.goods_id and c.id = g.cate_id and g.is_hot = 1 and g.state = 1 and i.cover = 1 and c.cname='小米' limit 12
    ";

    $result = query($link, $sql);
    //热销电脑
    $sql = "
        select
        i.iname,g.gname,g.price,g.msg,g.id
        from
        ".PRE."goods as g,".PRE."image as i,".PRE."category as c
        where
        g.id = i.goods_id and c.id = g.cate_id and g.is_hot = 1 and g.state = 1 and i.cover = 1 and c.cname='笔记本' limit 12
        ";

    $result_computer = query($link, $sql);
//    echo "<pre>";
//    print_r($result);
//    echo get_img_url(ROOT_URL . './upload',$result[0]['iname'],350);
//    die;

?>

    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <h2 class="text-center text-danger">热销小米手机</h2>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <?php if(empty($result)):?>
                <h3 class="text-center text-danger">暂无数据</h3>
            <?php else:?>
                <?php foreach ( $result as $item):?>
                    <div class="col-sm-6 col-md-3">
                        <div class="thumbnail">
                            <!-- 商品图片-->
                            <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                <img src="<?php echo get_img_url(ROOT_URL . './upload',$item['iname'],350)?>">
                            </a>
                            <div class="caption">
                                <!-- 商品名字-->
                                <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                    <h3><?php echo $item['gname']?></h3>
                                </a>
                                <!-- 商品介绍-->
                                <p style="overflow: hidden;height: 60px"><?php echo $item['msg'];?></p>
                                <!-- 商品价格-->
                                <h3>
                                    <span class="glyphicon glyphicon-jpy"></span>
                                    <?php echo $item['price']?>

                                        <a href="./com/buydo.php?act=zan&goods_id=<?php echo $item['id']?>" class="pull-right text-danger">
                                            <span class="glyphicon glyphicon-heart"></span>
                                        </a>


                                </h3>
                            </div>
                        </div>
                    </div>
                <?php endforeach;?>
            <?php endif;?>

        </div>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <h2 class="text-center text-danger">热销电脑</h2>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <?php if(empty($result_computer)):?>
                <h3 class="text-center text-danger">暂无数据</h3>
            <?php else:?>
                <?php foreach ( $result_computer as $item):?>
                    <div class="col-sm-6 col-md-3">
                        <div class="thumbnail">
                            <!-- 商品图片-->
                            <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                <img src="<?php echo get_img_url(ROOT_URL . './upload',$item['iname'],350)?>">
                            </a>
                            <div class="caption">
                                <!-- 商品名字-->
                                <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                    <h3><?php echo $item['gname']?></h3>
                                </a>
                                <!-- 商品介绍-->
                                <p style="overflow: hidden;height: 60px"><?php echo $item['msg'];?></p>
                                <!-- 商品价格-->
                                <h3>
                                    <span class="glyphicon glyphicon-jpy"></span>
                                    <?php echo $item['price']?>
                                    <a href="./com/buydo.php?act=zan&goods_id=<?php echo $item['id']?>" class="pull-right text-danger">
                                        <span class="glyphicon glyphicon-heart"></span>
                                    </a>
                                </h3>
                            </div>
                        </div>
                    </div>
                <?php endforeach;?>
            <?php endif;?>

        </div>
    </div>
